<extend name="Public/base"/>

<block name="body">
    <script type="text/javascript" src="__STATIC__/ColorPicker/jquery.js"></script>
    <script type="text/javascript" src="__STATIC__/ColorPicker/jquery.colorpicker.js"></script>
    <script type="text/javascript" src="__STATIC__/uploadify/jquery.uploadify.min.js"></script>
    <div class="main-title">
        <h2>装修店铺</h2>
    </div>
    <ul class="tab-nav nav">
        <li class="current"><a href="javascript:void(0)">基本信息</a></li>
    </ul>
    <form action="{:U()}" method="post" class="form-horizontal">
        <div class="tab-content">
            <div class="form-item">
                <div class="controls">
                    <label class="item-label">商家logo</label>
                    <input type="file" id="upload_picture1">
                    <input type="hidden" name="shop_logo" id="logo" value="{$list['shop_logo']|default=''}"/>
                    <div class="upload-img-box">
                        <div class="upload-pre-item"><img src="{$list['shop_logos']}"/></div>
                    </div>
                </div>
                <script type="text/javascript">
                    //上传图片
                    /* 初始化上传插件 */
                    $("#upload_picture1").uploadify({
                        "height"          : 30,
                        "swf"             : "__STATIC__/uploadify/uploadify.swf",
                        "fileObjName"     : "download",
                        "buttonText"      : "上传图片",
                        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                        "width"           : 120,
                        'removeTimeout'	  : 1,
                        'fileTypeExts'	  : '*.jpg; *.png; *.gif;*.jpeg;',
                        "onUploadSuccess" : uploadPicture1,
                        'onFallback' : function() {
                            alert('未检测到兼容版本的Flash.');
                        }
                    });
                    function uploadPicture1(file, data){
                        var data = $.parseJSON(data);
                        var src = '';
                        if(data.status){
                            $("#logo").val(data.id);
                            src = data.url || '__ROOT__' + data.path;
                            console.log(src);
                            $("#logo").parent().find('.upload-img-box').html(
                                '<div class="upload-pre-item"><img src="' + src + '"/></div>'
                            );
                        } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                                $('#top-alert1').find('button').click();
                                $(that).removeClass('disabled').prop('disabled',false);
                            },1500);
                        }
                    }
                </script>
            </div>
            <div class="form-item">
                <div class="controls">
                    <label class="item-label">商家相册</label>
                    <input type="file" id="upload_picture">
                    <input type="hidden" name="shop_thumb" id="goods_img" value="{$list['shop_thumb']|default=''}"/>
                    <div class="upload-img-box upload-img-box1">
                        <volist name="list['shop_thumbs']" id="v"><div class="upload-pre-item upload-pre-item1"><img src="{$v['url']}"/></div><span class="span1" uid="{$v['id']}">x</span></volist>
                    </div>
                </div>
                <script type="text/javascript">
                    //上传图片
                    /* 初始化上传插件 */
                    $("#upload_picture").uploadify({
                        "height"          : 30,
                        "swf"             : "__STATIC__/uploadify/uploadify.swf",
                        "fileObjName"     : "download",
                        "buttonText"      : "上传图片",
                        "uploader"        : "{:U('File/uploadPicture',array('session_id'=>session_id()))}",
                        "width"           : 120,
                        'removeTimeout'	  : 1,
                        'fileTypeExts'	  : '*.jpg; *.png; *.gif;*.jpeg;',
                        "onUploadSuccess" : uploadPicture,
                        'onFallback' : function() {
                            alert('未检测到兼容版本的Flash.');
                        }
                    });
                    function uploadPicture(file, data){
                        var data = $.parseJSON(data);
                        var src = '';
                        if(data.status){
                            var icon=$("#goods_img").val();
                            if(icon){
                                $("#goods_img").val(icon+','+data.id);
                            }else {
                                $("#goods_img").val(data.id);
                            }
                            src = data.url || '__ROOT__' + data.path;
                            var html=$("#goods_img").parent().find('.upload-img-box1').html();
                            if(html){
                                $("#goods_img").parent().find('.upload-img-box1').html(
                                    html+ '<div class="upload-pre-item upload-pre-item1"><img src="' + src + '"/></div><span class="span1" uid="'+data.id+'">x</span>'
                                );
                            }else {
                                $("#goods_img").parent().find('.upload-img-box1').html(
                                    '<div class="upload-pre-item upload-pre-item1"><img src="' + src + '"/></div><span class="span1" uid="'+data.id+'">x</span>'
                                );
                            }

                        } else {
                            updateAlert(data.info);
                            setTimeout(function(){
                                $('#top-alert').find('button').click();
                                $(that).removeClass('disabled').prop('disabled',false);
                            },1500);
                        }
                    }
                    $('.span1').live('click',function () {
                        var id=$(this).attr('uid');
                        var index=$(this).index();
                        var str=$('#goods_img').val();
                        var arr=str.split(',');
                        var arr1=arr;
                        for ( var i = 0; i <arr.length; i++){
                            if(arr[i]==id){
                                arr1.splice(i,1);
                            }
                        }
                        $('#goods_img').val(arr1.join(','));
                        var index1=1;
                        if(index>1){
                            for (var i=2;i<index;i+=2){
                                index1++;
                            }
                        }
                        index=index-index1;
                        $('.span1').eq(index).remove();
                        $('.upload-pre-item1').eq(index).remove();
                    })
                </script>
            </div>
            <div class="form-item">
                <label class="item-label">店铺介绍</label>
                <div class="controls">
                    <textarea id="container" name="introduce">{$list['introduce']}</textarea>
                </div>
            </div>
            <div class="form-item">
                <input type="hidden" name="id" value="{$list['id']}">
                <button class="btn submit-btn ajax-post" id="submit" type="submit" target-form="form-horizontal">确 定</button>
                <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
            </div>
        </div>
    </form>
</block>

<block name="script">
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Shop/index')}');
    </script>
    <!-- 配置文件 -->
    <script type="text/javascript" src="__STATIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__STATIC__/ueditor/ueditor.all.min.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('container',{
            initialFrameWidth:"100%",
            initialFrameHeight:200,
            wordCount:false,
            autoHeightEnabled:false,
            autoFloatEnabled:false
        });
    </script>
</block>
